package com.shbaiche.bifenba.adapter.data;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.shbaiche.bifenba.R;
import com.shbaiche.bifenba.model.GankResults;
import com.shbaiche.bifenba.model.data.ShooterVo;
import com.shbaiche.bifenba.view.CircularImage;

import butterknife.BindView;
import cn.droidlover.xdroid.base.SimpleRecAdapter;
import cn.droidlover.xdroid.kit.KnifeKit;
import cn.droidlover.xdroidbase.imageloader.ILFactory;

/**
 * Created by wanglei on 2016/12/10.
 */

public class DataPlayerListAdapter extends SimpleRecAdapter<ShooterVo, DataPlayerListAdapter.ViewHolder> {


    public DataPlayerListAdapter(Context context) {
        super(context);
    }

    @Override
    public ViewHolder newViewHolder(View itemView) {
        return new ViewHolder(itemView);
    }

    @Override
    public int getLayoutId() {
        return R.layout.adapter_data_player_list;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        ShooterVo item = data.get(position);

        ILFactory.getLoader().loadNet(holder.ivLogo, item.getLogo(), null);
        holder.tvName.setText(item.getPlayerName());
        holder.tvTeam.setText(item.getTeamName());
        holder.tvValue.setText(item.getValue());

        holder.tvRank.setText(""+item.getRank());

        if(item.getRank() > 3){
            holder.tvRank.setTextColor(Color.BLACK);
        }else{
            holder.tvRank.setTextColor(Color.RED);
        }


        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (getRecItemClick() != null) {

                }
            }
        });
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.iv_logo)
        CircularImage ivLogo;

        @BindView(R.id.tv_rank)
        TextView tvRank;

        @BindView(R.id.tv_name)
        TextView tvName;

        @BindView(R.id.tv_team)
        TextView tvTeam;

        @BindView(R.id.tv_value)
        TextView tvValue;



        public ViewHolder(View itemView) {
            super(itemView);
            KnifeKit.bind(this, itemView);
        }
    }
}
